package cpr;

import java.util.Iterator;
import java.util.List;

import cpr.data.HLVector;


public class Rule {
    private int[] attrs = new int[3];
    public int ruleNr;
    public int ruleNrGlobal;
    public String attrName;
    public String attrValue;
    public int attrValueDigital;
    public String score;
//    private int _hashCode;
    public String[] hl;
    public int[] hl_digital;
    public String[] hl_file_values;
    static public int[] HL_LEVEL;
    
    
    public void copyFrom(Rule copyFrom) {
    	this.attrs[0] = copyFrom.attrs[0];
    	this.attrs[1] = copyFrom.attrs[1];
    	this.attrs[2] = copyFrom.attrs[2];
    	this.ruleNr = copyFrom.ruleNr;
    	this.attrName = copyFrom.attrName;
    	this.attrValue = copyFrom.attrValue;
    	this.attrValueDigital = copyFrom.attrValueDigital;
    	this.score = copyFrom.score;
//    	this._hashCode = copyFrom._hashCode;
    	this.hl = copyFrom.hl;
    	this.hl_digital = copyFrom.hl_digital;
    }
    
    
    
    public String getHLValue(int hl_index) {
    	return hl[hl_index];
    }
    public int getHLValueDigital(int hl_index) {
    	return hl_digital[hl_index];
    }
    public void setHLValueDigital(int hl_index, int value) {
    	hl_digital[hl_index] = value;
    }
    public void setAttrValueDigital(int value) {
    	attrValueDigital = value;
    }
    public int getOtherAttr(int attrId) { 
        return attrs[attrId]; 
    };
    public void setOtherAttr(int attrId, int value) {
        attrs[attrId]=value;
    }
    public int getScore() {
        int score = 0;
        for (int h=0;h<HLIS.length;h++) {
            score += HL_SCORE[HLH[HLIS[h]][HL_LEVEL[HLIS[h]]]];
        }
        return score;
    }
    

    public String getKeyValueOld(int keyId) {
    	switch (keyId) {
    		case CPRConst.KEY_SALESORG:
    				return hl[HLH[HLI_SALESORG][HL_LEVEL[HLI_SALESORG]]];
    		case CPRConst.KEY_SOLD_TO:
				return hl[HLH[HLI_SOLD_TO][HL_LEVEL[HLI_SOLD_TO]]];
    		case CPRConst.KEY_SHIP_TO:
				return hl[HLH[HLI_SHIP_TO][HL_LEVEL[HLI_SHIP_TO]]];
    		case CPRConst.KEY_SHIP_TO_XT:
				return hl[HLH[HLI_SHIP_TO_XTERM][HL_LEVEL[HLI_SHIP_TO_XTERM]]];
    		case CPRConst.KEY_DUCPR:
				return hl[HLH[HLI_DUCPR][HL_LEVEL[HLI_DUCPR]]];
    	}
    	return null;
    }    
    
    public String getKeyValue(int keyId) {
    	return hl[HLH[keyId][HL_LEVEL[HLI_SALESORG]]];
    }    
    
    public String toLongString() {
        StringBuffer sb = new StringBuffer();
        sb.append("#"+ruleNr+":\n");
        
        for (int h=0;h<HLIS.length;h++) {
//        	sb.append(hl_level[h]+":      ");
            sb.append("      ");
            for (int i=0;i<HLH[HLIS[h]].length;i++) {
                sb.append(stringWidth(""+getHLValueDigital(HLH[HLIS[h]][i]),8)+" ");
            }
            sb.append("\n");
        }
        sb.append(" ATTR_NAME   :"+attrName+"\n");
        sb.append(" ATTR_VALUE  :"+attrValue+"\n");
        sb.append(" SCORE       :"+score+"\n");
//        sb.append("-------------+\n");
        return sb.toString();
    }
    public String stringWidth(String str, int width) {
        StringBuffer res = new StringBuffer(width);
        if (str==null) str ="";
        for (int i =0;i<width-str.length();i++) {
            res.append(" ");
        }
        res.append(str);
        return res.toString();
    }
    public boolean equals(Object obj) {
        if (obj instanceof Rule) {
            return (hashCode()==obj.hashCode());
        }
        return false;
    }
//    public int hashCode() {
//        return _hashCode;
//    }
//    private void computeHashCode() {
//        StringBuffer sb = new StringBuffer();
//        for (int h=0;h<HLIS.length;h++) {
//            for (int i=0;i<HLH[HLIS[h]].length;i++) {
//                sb.append(stringWidth(""+getHLValueDigital(HLH[HLIS[h]][i]),8)+";");
//            }
//        }
//        sb.append(attrName+";");
//        sb.append(attrValue+";");
//        _hashCode = sb.toString().hashCode();
//    }
    public String toString() {
        StringBuffer sb = new StringBuffer();
        sb.append("[");
        sb.append(stringWidth(""+ruleNr,6)+";");
        for (int h=0;h<HLIS.length;h++) {
            for (int i=0;i<HLH[HLIS[h]].length;i++) {
                sb.append(stringWidth(""+getHLValueDigital(HLH[HLIS[h]][i]),8)+";");
            }
        }
        sb.append(attrName+";");
        sb.append(attrValue+";");
        sb.append(score);
        sb.append("]");
        return sb.toString();
    }    


    public final static int HLI_SALESORG = 0;
    public final static int HLI_SOLD_TO = 1;
    public final static int HLI_SHIP_TO = 2;
    public final static int HLI_SHIP_TO_XTERM = 3;
    public final static int HLI_DUCPR = 4;
    
    public final static int HL_SALESORG_ROOT=0;
    public final static int HL_SALESORG_REGION=1;
    public final static int HL_SALESORG_SUBREG=2;
    public final static int HL_SALESORG_COUNTRY=3;
    public final static int HL_SALESORG_COMPANY=4;
    public final static int HL_SALESORG_ORG=5;
    public final static int[] HLH_SALESORG = new int[] {HL_SALESORG_ROOT, HL_SALESORG_REGION, HL_SALESORG_SUBREG, HL_SALESORG_COUNTRY,HL_SALESORG_COMPANY,HL_SALESORG_ORG  };

    public final static int HL_SHIP_TO_ROOT=6;
    public final static int HL_SHIP_TO_CH1=7;
    public final static int HL_SHIP_TO_CH2=8;
    public final static int HL_SHIP_TO_CH3=9;
    public final static int HL_SHIP_TO_REGION=10;
    public final static int HL_SHIP_TO_SUBREG=11;
    public final static int HL_SHIP_TO_COUNTRY=12;
    public final static int HL_SHIP_TO_CUSTOMER=13;
    public final static int[] HLH_SHIP_TO = new int[] {
        HL_SHIP_TO_ROOT, HL_SHIP_TO_REGION,  HL_SHIP_TO_SUBREG, HL_SHIP_TO_COUNTRY,HL_SHIP_TO_CUSTOMER
    };
    public final static int[] HLH_SHIP_TO_XTERM = new int[] {
        HL_SHIP_TO_ROOT, HL_SHIP_TO_CH1,  HL_SHIP_TO_CH2, HL_SHIP_TO_CH3,HL_SHIP_TO_CUSTOMER
    };
    public final static int HL_SOLD_TO_ROOT=14;
    public final static int HL_SOLD_TO_REGION=15;
    public final static int HL_SOLD_TO_SUBREG=16;
    public final static int HL_SOLD_TO_COUNTRY=17;
    public final static int HL_SOLD_TO_CUSTOMER=18;
    public final static int[] HLH_SOLD_TO = new int[] {
        HL_SOLD_TO_ROOT, HL_SOLD_TO_REGION,  HL_SOLD_TO_SUBREG, HL_SOLD_TO_COUNTRY,HL_SOLD_TO_CUSTOMER
    };
    public final static int HL_DUCPR_ROOT=19;
    public final static int HL_DUCPR_PRODH1=20;
    public final static int HL_DUCPR_PRODH2=21;
    public final static int HL_DUCPR_PRODH3=22;
    public final static int HL_DUCPR_PRODH4=23;
    public final static int HL_DUCPR_PRODG=24;
    public final static int HL_DUCPR_PRODM=25;
    public final static int[] HLH_DUCPR = new int[] {
        HL_DUCPR_ROOT, HL_DUCPR_PRODH1,  HL_DUCPR_PRODH2, HL_DUCPR_PRODH3,HL_DUCPR_PRODH4, HL_DUCPR_PRODG, HL_DUCPR_PRODM
    };
    public final static int HL_SIZE = 26;
    public final static int[] HL_SCORE;
    public final static int[][] HLH;
    static {
    	HLH = new int [5][];
    	HLH[HLI_SALESORG] = HLH_SALESORG;
    	HLH[HLI_SOLD_TO] = HLH_SOLD_TO;
    	HLH[HLI_SHIP_TO] = HLH_SHIP_TO;
    	HLH[HLI_SHIP_TO_XTERM] = HLH_SHIP_TO_XTERM;
    	HLH[HLI_DUCPR] = HLH_DUCPR;
        
        HL_SCORE = new int[HL_SIZE];
        HL_SCORE[HL_SALESORG_ROOT]      = 0;
        HL_SCORE[HL_SALESORG_REGION]    = 2;
        HL_SCORE[HL_SALESORG_SUBREG]    = 64;
        HL_SCORE[HL_SALESORG_COUNTRY]   = 2048;
        HL_SCORE[HL_SALESORG_COMPANY]   = 65536;
        HL_SCORE[HL_SALESORG_ORG]       = 524288;
        HL_SCORE[HL_SHIP_TO_ROOT]       = 0;
        HL_SCORE[HL_SHIP_TO_CH1]        = 16;
        HL_SCORE[HL_SHIP_TO_CH2]        = 512;
        HL_SCORE[HL_SHIP_TO_CH3]        = 16384;
        HL_SCORE[HL_SHIP_TO_REGION]     = 8;
        HL_SCORE[HL_SHIP_TO_SUBREG]     = 256;
        HL_SCORE[HL_SHIP_TO_COUNTRY]    = 8192;
        HL_SCORE[HL_SHIP_TO_CUSTOMER]   = 2097152;
        HL_SCORE[HL_SOLD_TO_ROOT]       = 0;
        HL_SCORE[HL_SOLD_TO_REGION]     = 4;
        HL_SCORE[HL_SOLD_TO_SUBREG]     = 128;
        HL_SCORE[HL_SOLD_TO_COUNTRY]    = 4096;
        HL_SCORE[HL_SOLD_TO_CUSTOMER]   = 1048576;
        HL_SCORE[HL_DUCPR_ROOT]         = 0;
        HL_SCORE[HL_DUCPR_PRODH1]       = 32;
        HL_SCORE[HL_DUCPR_PRODH2]       = 1024;
        HL_SCORE[HL_DUCPR_PRODH3]       = 32768;
        HL_SCORE[HL_DUCPR_PRODH4]       = 131072;
        HL_SCORE[HL_DUCPR_PRODG]        = 262144;
        HL_SCORE[HL_DUCPR_PRODM]        = 4194304;
        
        HL_LEVEL = new int[5];
        HL_LEVEL[HLI_SALESORG]        = HLH[HLI_SALESORG].length-1;
        HL_LEVEL[HLI_SOLD_TO]         = HLH[HLI_SOLD_TO].length-1; 
        HL_LEVEL[HLI_SHIP_TO]         = HLH[HLI_SHIP_TO].length-2; 
        HL_LEVEL[HLI_SHIP_TO_XTERM]   = HLH[HLI_SHIP_TO_XTERM].length-2; 
        HL_LEVEL[HLI_DUCPR]           = HLH[HLI_DUCPR].length-1; 
                
        
    }

    public final static int[] HLIS = new int[] {HLI_SALESORG,HLI_SOLD_TO, HLI_SHIP_TO, HLI_SHIP_TO_XTERM, HLI_DUCPR};


 
    protected static String getRandomCoorelatedAttrValue(long[][] rh) {
        long v = 0;
        if (rh[2][0]==0) {
            v = 1;
        } else if (rh[2][0]==1) {
            v = 2;
        } else if (rh[2][0]==2) {
            v = 3;
        } else if (rh[1][0]==0) {
            v = 4;
        } else if (rh[1][0]==1) {
            v = 5;
        } else if (rh[1][0]==2) {
            v = 6;
        } else if (rh[0][0]==1) {
            v = 7;
        } else if (rh[0][0]==2) {
            v = 8;
        } else {
            v = 10;
        }
        String str = "av_"+v;
        return str;
    }
    
    protected static long[][] getRandomCoorelatedData() {
        long[][] rh = new long[Rule.HLIS.length][];
        for (int h=0;h<Rule.HLIS.length;h++) {
            rh[h] = new long[Rule.HLH[h].length-1];
            for (int i=0;i<Rule.HLH[h].length-1;i++) {
                rh[h][i] = (int)(Math.random()*4);
            }
        }
        
        int s = (int)(Math.random()*8);
        switch (s) {
        case 0:
            rh[2][0] = 0;
            break;
        case 1:
            rh[2][0] = 1;
            break;
        case 2:
            rh[2][0] = 2;
            break;
        case 3:
            rh[1][0] = 0;             
            break;
        case 4:
            rh[1][0] = 1;             
            break;
        case 5:
            rh[1][0] = 2;             
            break;
        case 6:
            rh[0][0] = 1;
            break;
        case 7:
            rh[0][0] = 2;
            break;
        default:
            rh[0][0] = rh[0][0];
        }
        
        return rh;
    }
   
    public Rule() {
    	ruleNr = -1;
    	ruleNrGlobal = -1;
    	
    }
    public Rule(Rule copyFrom) {
    	this();
    	copyFrom(copyFrom);
    }
    

     
    private static int intOrMinusOne(String s) {
    	try {
    		return Integer.parseInt(s);
    	}catch (Exception ex) {
    		
    	}
    	return -1;
    	
    }
//    private static void internalCreateFromHLLevel(Rule r) {
//        r.hl_level = new int[5];
//        r.hl_level[HLI_SALESORG]		= HLH[HLI_SALESORG].length-1;
//        r.hl_level[HLI_SOLD_TO]			= HLH[HLI_SOLD_TO].length-1; 
//        r.hl_level[HLI_SHIP_TO]			= HLH[HLI_SHIP_TO].length-2; 
//        r.hl_level[HLI_SHIP_TO_XTERM]	= HLH[HLI_SHIP_TO_XTERM].length-2; 
//        r.hl_level[HLI_DUCPR]			= HLH[HLI_DUCPR].length-1; 
//        
//    }

     public static void internalCreateFromHLS(Rule r, String[] s) {
        r.hl[HLH[HLIS[0]][0]] = "*";
        r.hl[HLH[HLIS[0]][1]] = s[22];
        r.hl[HLH[HLIS[0]][2]] = s[23];
        r.hl[HLH[HLIS[0]][3]] = s[25];
        r.hl[HLH[HLIS[0]][4]] = s[24];
        r.hl[HLH[HLIS[0]][5]] = s[0];
        r.hl[HLH[HLIS[1]][0]] = "*";
        r.hl[HLH[HLIS[1]][1]] = s[35];
        r.hl[HLH[HLIS[1]][2]] = s[36] ;
        r.hl[HLH[HLIS[1]][3]] = s[37];
        r.hl[HLH[HLIS[1]][4]] = s[1];
        r.hl[HLH[HLIS[2]][0]] = "*";
        r.hl[HLH[HLIS[2]][1]] = s[29];
        r.hl[HLH[HLIS[2]][2]] = s[30];
        r.hl[HLH[HLIS[2]][3]] = s[31];
        r.hl[HLH[HLIS[2]][4]] = s[2];
        r.hl[HLH[HLIS[3]][0]] = "*";
        r.hl[HLH[HLIS[3]][1]] = s[43];
        r.hl[HLH[HLIS[3]][2]] = s[44];
        r.hl[HLH[HLIS[3]][3]] = s[45];
        r.hl[HLH[HLIS[3]][4]] = s[2];
        r.hl[HLH[HLIS[4]][0]] = "*";
        r.hl[HLH[HLIS[4]][1]] = s[38];
        r.hl[HLH[HLIS[4]][2]] = s[39];
        r.hl[HLH[HLIS[4]][3]] = s[40];
        r.hl[HLH[HLIS[4]][4]] = s[41];
        r.hl[HLH[HLIS[4]][5]] = s[42];
        r.hl[HLH[HLIS[4]][6]] = s[3];

        r.attrValue         = s[5];
}
    
    private static void internalCreateToHLS(Rule r, String[] s) {
    	s[22] = r.hl[HLH[HLIS[0]][1]];
		s[23] = r.hl[HLH[HLIS[0]][2]];
		s[25] = r.hl[HLH[HLIS[0]][3]];
		s[24] = r.hl[HLH[HLIS[0]][4]];
		s[0] = r.hl[HLH[HLIS[0]][5]];
		s[35] = r.hl[HLH[HLIS[1]][1]];
		s[36] = r.hl[HLH[HLIS[1]][2]];
		s[37] = r.hl[HLH[HLIS[1]][3]];
		s[1] = r.hl[HLH[HLIS[1]][4]];
		s[29] = r.hl[HLH[HLIS[2]][1]];
		s[30] = r.hl[HLH[HLIS[2]][2]];
		s[31] = r.hl[HLH[HLIS[2]][3]];
		s[2] = r.hl[HLH[HLIS[2]][4]];
		s[43] = r.hl[HLH[HLIS[3]][1]];
		s[44] = r.hl[HLH[HLIS[3]][2]];
		s[45] = r.hl[HLH[HLIS[3]][3]];
		s[2] = r.hl[HLH[HLIS[3]][4]];
		s[38] = r.hl[HLH[HLIS[4]][1]];
		s[39] = r.hl[HLH[HLIS[4]][2]];
		s[40] = r.hl[HLH[HLIS[4]][3]];
		s[41] = r.hl[HLH[HLIS[4]][4]];
		s[42] = r.hl[HLH[HLIS[4]][5]];
		s[3] = r.hl[HLH[HLIS[4]][6]];
		s[5] = "" + r.attrValue;
    }
    private static void internalCreateToHLD(Rule r, String[] s) {
    	s[50+22] = "" + r.hl_digital[HLH[HLIS[0]][1]];
		s[50+23] = "" + r.hl_digital[HLH[HLIS[0]][2]];
		s[50+25] = "" + r.hl_digital[HLH[HLIS[0]][3]];
		s[50+24] = "" + r.hl_digital[HLH[HLIS[0]][4]];
		s[50+0] = "" + r.hl_digital[HLH[HLIS[0]][5]];
		s[50+35] = "" + r.hl_digital[HLH[HLIS[1]][1]];
		s[50+36] = "" + r.hl_digital[HLH[HLIS[1]][2]];
		s[50+37] = "" + r.hl_digital[HLH[HLIS[1]][3]];
		s[50+1] = "" + r.hl_digital[HLH[HLIS[1]][4]];
		s[50+29] = "" + r.hl_digital[HLH[HLIS[2]][1]];
		s[50+30] = "" + r.hl_digital[HLH[HLIS[2]][2]];
		s[50+31] = "" + r.hl_digital[HLH[HLIS[2]][3]];
		s[50+2] = "" + r.hl_digital[HLH[HLIS[2]][4]];
		s[50+43] = "" + r.hl_digital[HLH[HLIS[3]][1]];
		s[50+44] = "" + r.hl_digital[HLH[HLIS[3]][2]];
		s[50+45] = "" + r.hl_digital[HLH[HLIS[3]][3]];
		s[50+2] = "" + r.hl_digital[HLH[HLIS[3]][4]];
		s[50+38] = "" + r.hl_digital[HLH[HLIS[4]][1]];
		s[50+39] = "" + r.hl_digital[HLH[HLIS[4]][2]];
		s[50+40] = "" + r.hl_digital[HLH[HLIS[4]][3]];
		s[50+41] = "" + r.hl_digital[HLH[HLIS[4]][4]];
		s[50+42] = "" + r.hl_digital[HLH[HLIS[4]][5]];
		s[50+3] = "" + r.hl_digital[HLH[HLIS[4]][6]];
        
		s[50+5] = "" + r.attrValueDigital;

    }
    
    public static void internalCreateFromHLD(Rule r, String[] s) {
        r.hl_digital[HLH[HLIS[0]][0]] = 0;
        r.hl_digital[HLH[HLIS[0]][1]] = intOrMinusOne(s[50+22]);
        r.hl_digital[HLH[HLIS[0]][2]] = intOrMinusOne(s[50+23]);
        r.hl_digital[HLH[HLIS[0]][3]] = intOrMinusOne(s[50+25]);
        r.hl_digital[HLH[HLIS[0]][4]] = intOrMinusOne(s[50+24]);
        r.hl_digital[HLH[HLIS[0]][5]] = intOrMinusOne(s[50+0]);
        r.hl_digital[HLH[HLIS[1]][0]] = 0;
        r.hl_digital[HLH[HLIS[1]][1]] = intOrMinusOne(s[50+35]);
        r.hl_digital[HLH[HLIS[1]][2]] = intOrMinusOne(s[50+36]) ;
        r.hl_digital[HLH[HLIS[1]][3]] = intOrMinusOne(s[50+37]);
        r.hl_digital[HLH[HLIS[1]][4]] = intOrMinusOne(s[50+1]);
        r.hl_digital[HLH[HLIS[2]][0]] = 0;
        r.hl_digital[HLH[HLIS[2]][1]] = intOrMinusOne(s[50+29]);
        r.hl_digital[HLH[HLIS[2]][2]] = intOrMinusOne(s[50+30]);
        r.hl_digital[HLH[HLIS[2]][3]] = intOrMinusOne(s[50+31]);
        r.hl_digital[HLH[HLIS[2]][4]] = intOrMinusOne(s[50+2]);
        r.hl_digital[HLH[HLIS[3]][0]] = 0;
        r.hl_digital[HLH[HLIS[3]][1]] = intOrMinusOne(s[50+43]);
        r.hl_digital[HLH[HLIS[3]][2]] = intOrMinusOne(s[50+44]);
        r.hl_digital[HLH[HLIS[3]][3]] = intOrMinusOne(s[50+45]);
        r.hl_digital[HLH[HLIS[3]][4]] = intOrMinusOne(s[50+2]);
        r.hl_digital[HLH[HLIS[4]][0]] = 0;
        r.hl_digital[HLH[HLIS[4]][1]] = intOrMinusOne(s[50+38]);
        r.hl_digital[HLH[HLIS[4]][2]] = intOrMinusOne(s[50+39]);
        r.hl_digital[HLH[HLIS[4]][3]] = intOrMinusOne(s[50+40]);
        r.hl_digital[HLH[HLIS[4]][4]] = intOrMinusOne(s[50+41]);
        r.hl_digital[HLH[HLIS[4]][5]] = intOrMinusOne(s[50+42]);
        r.hl_digital[HLH[HLIS[4]][6]] = intOrMinusOne(s[50+3]);
        
        r.attrValueDigital         = intOrMinusOne(s[50+5]);
        
    }
    
    
    public String toHLDigitalString() {
    	String[] s = hl_file_values;
    	internalCreateToHLD(this,s);
    	internalCreateToHLS(this,s);
    	StringBuffer sb = new StringBuffer();
    	for (int i = 0; i < s.length; i++) {
    		if (s[i].equals("")) {
    			sb.append(" ");
    		}
			sb.append(s[i]+"\t");
		}
    	
    	char tab = 9; 
        String ts = ""+tab;
        String ts2 = new String(new char[] {tab});
        String str = sb.toString();
        String[] sp = str.split(ts2);
        
    	if (sp[5].trim().equals("")) {
    		int problem = 1;
    	}
    	return sb.toString();
    }
    
    public static int getHLIndexByName(int hlGroupIndex, String hlIndexName) {
    	switch (hlGroupIndex) {
	    	case HLI_DUCPR: return HL_DUCPR_PRODH1;
	    	case HLI_SALESORG: return HL_SALESORG_ORG;
	    	case HLI_SHIP_TO: return HL_SHIP_TO_COUNTRY;
	    	case HLI_SHIP_TO_XTERM: return HL_SHIP_TO_CH1;
	    	case HLI_SOLD_TO: return HL_SOLD_TO_CUSTOMER;
    	}
    	return -1;
    }
    
    public static int getIndexOfInHLH(int hlGroupIndex, int hlIndex) {
    	int[] indexes = HLH[hlGroupIndex];
    	for (int i = 0; i < indexes.length; i++) {
			if (indexes[i]==hlIndex) return i;
		}
    	return -1;
    }
    
    
    public static Rule createFromString(String str) {
        throw new RuntimeException("not implemented");
//        Rule r = new Rule();
//        try {
//            String[] s = str.split(";");
//            r.ruleNr            = Integer.parseInt(s[0]);
//            
//            r.hl = new String[HL_SIZE];
//            r.hl_level = new int[5];
//            r.hl_level[HLI_SALESORG]		= getIndexOfInHLH(HLI_SALESORG, getHLIndexByName(HLI_SALESORG,s[7] ));
//            r.hl_level[HLI_SOLD_TO]		= getIndexOfInHLH(HLI_SOLD_TO, getHLIndexByName(HLI_SOLD_TO,s[8] ));
//            r.hl_level[HLI_SHIP_TO]		= getIndexOfInHLH(HLI_SHIP_TO, getHLIndexByName(HLI_SHIP_TO,s[9] ));
//            r.hl_level[HLI_DUCPR]		= getIndexOfInHLH(HLI_DUCPR, getHLIndexByName(HLI_DUCPR,s[10] ));
//            r.hl_level[HLI_SHIP_TO_XTERM]		= getIndexOfInHLH(HLI_SHIP_TO_XTERM, getHLIndexByName(HLI_SHIP_TO_XTERM,s[11] ));
//
//            r.hl[HLH[HLI_SALESORG][r.hl_level[HLI_SALESORG]]] = s[1];
//            r.hl[HLH[HLI_SOLD_TO][r.hl_level[HLI_SOLD_TO]]] = s[2];
//            r.hl[HLH[HLI_SHIP_TO][r.hl_level[HLI_SHIP_TO]]] = s[3];
//            r.hl[HLH[HLI_SHIP_TO_XTERM][r.hl_level[HLI_SHIP_TO_XTERM]]] = s[3];
//            r.hl[HLH[HLI_DUCPR][r.hl_level[HLI_DUCPR]]] = s[4];
//                  
//            r.attrName          = s[12];
//            r.attrValue         = s[13];
//            r.score             = s[17];
////            r.computeHashCode();
//        } catch (Exception ex) {
//          ex.printStackTrace();   
//        }
//        return r;
        
    }
}
